const compose = require('koa-compose')
const glob = require('glob')
const { resolve } = require('path')

registerRouter = () => {
  let routers = [];
    glob.sync(resolve(__dirname, './', '**/*.js'))
        .filter(value => (value.indexOf('index.js') === -1))
        .map(router => {
            routers.push(require(router).routes())
            routers.push(require(router).allowedMethods())
        })
    return compose(routers)
}

module.exports = registerRouter






/*/const Router = require('koa-router')

const router = new Router({
    prefix: '/api/v1'
})

module.exports = router
*/


/**
 * 
 * 
 * 
 * 
 * const ArticleController = require('../controllers/article')

文章接口
 
// 创建文章接口（路由）
router.post('/article', ArticleController.create);
// 获取文章详情接口（路由）
router.get('/article/:id', ArticleController.detail);

module.exports = router
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 */
